﻿using Microsoft.VisualBasic.FileIO;
using System.IO;

namespace CommonUtils
{
    /// <summary>
    /// 文件操作类
    /// </summary>
    public static class FrameworkFileUtil
    {
        /// <summary>
        /// 删除文件到回收站
        /// </summary>
        public static void DeleteToRecycleBin(string path)
        {
            if (File.Exists(path))
            {
                FileSystem.DeleteFile(path, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
                ConsoleUtil.WriteLine("delete file to recycle bin: " + path);
            }
        }

        /// <summary>
        /// 删除文件到回收站
        /// </summary>
        public static void DeleteToRecycleBin(this FileInfo file)
        => DeleteToRecycleBin(file.FullName);
    }
}
